//
//  SetViewController.m
//  QQ-Music
//
//  Created by lanou3g on 15/10/30.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "SetViewController.h"
#import "AppDelegate.h"
#import "Colours.h"



@interface SetViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) IBOutlet UITableView *mainTableView;
//储存每行cell显示的内容
@property(nonatomic, retain)NSArray *dataArray;

@end

@implementation SetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"设置";
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    menuBtn.frame = CGRectMake(0, 0, 20, 18);
    [menuBtn setBackgroundImage:[UIImage imageNamed:@"11.png"] forState:UIControlStateNormal];
    [menuBtn addTarget:self action:@selector(openOrCloseLeftList) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:menuBtn];
    
    //实现代理
    self.mainTableView.delegate = self;
    self.mainTableView.dataSource = self;
   
}


#pragma mark - Button点击事件
- (void) openOrCloseLeftList
{
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    
    if (tempAppDelegate.LeftSlideVC.closed)
    {
        [tempAppDelegate.LeftSlideVC openLeftView];
    }
    else
    {
        [tempAppDelegate.LeftSlideVC closeLeftView];
    }
}

#pragma mark - 实现代理方法
//分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

//每组cell数目
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 5;
    } else if (section == 1) {
        return 5;
        
    } else {
        
        return 3;
    }
}

//cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cell_id =@"flag";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cell_id];
    if (cell == nil) {
        //创建cell,不能少....
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cell_id];
        //cell.textLabel.text = self.dataArray[indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //cell.contentView.backgroundColor = [UIColor pinkColor];
        
    }
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        cell.textLabel.text = @"在线听歌音质";
    } else if (indexPath.section == 0 && indexPath.row == 1) {
        cell.textLabel.text = @"歌单自动下载";
    } else if (indexPath.section == 0 && indexPath.row == 2) {
        cell.textLabel.text = @"DTS音效";
    } else if (indexPath.section == 0 && indexPath.row == 3) {
        cell.textLabel.text = @"边听边存";
        UISwitch *switchView = [[UISwitch alloc] init];
        [switchView setOn:YES];
        cell.accessoryView = switchView;
    } else if (indexPath.section == 0 && indexPath.row == 4) {
        cell.textLabel.text = @"歌曲存储位置设置";
        cell.detailTextLabel.text = @"当前位置:";
    } else if (indexPath.section == 1 && indexPath.row == 0) {
        cell.textLabel.text = @"锁屏歌词";
    } else if (indexPath.section == 1 && indexPath.row == 1) {
        cell.textLabel.text = @"桌面歌词";
        UISwitch *switchView = [[UISwitch alloc] init];
        [switchView setOn:YES];
        cell.accessoryView = switchView;
    } else if (indexPath.section == 1 && indexPath.row == 2) {
        UISwitch *switchView = [[UISwitch alloc] init];
        [switchView setOn:YES];
        cell.accessoryView = switchView;
        cell.textLabel.text = @"自动进入播放页";
    } else if (indexPath.section == 1 && indexPath.row == 3) {
        cell.textLabel.text = @"专辑封面自动旋转";
        UISwitch *switchView = [[UISwitch alloc] init];
        [switchView setOn:YES];
        cell.accessoryView = switchView;
    } else if (indexPath.section == 1 && indexPath.row == 4) {
        cell.textLabel.text = @"桌面插件";
    } else if (indexPath.section == 2 && indexPath.row == 0) {
        cell.textLabel.text = @"铃声管理";
    } else if (indexPath.section == 2 && indexPath.row == 1) {
        cell.textLabel.text = @"分享";
    } else {
        cell.textLabel.text = @"摇一摇";
    }
    
    cell.textLabel.font = [UIFont systemFontOfSize:15.0];
    return cell;
}
//cell的颜色
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //cell.backgroundColor = [UIColor redColor];
    UIColor *color  = [[UIColor alloc] initWithRed:255.0/255 green:222.0/255 blue:249.0/255 alpha:1.0];
    cell.backgroundColor = color;
    //cell.selectedBackgroundView选中时的颜色
}

//cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

//每组头标题名称
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return @"试听下载";
    } else if (section == 1) {
        return @"歌词与播放";
    } else {
        return @"通用";
    }
}

//头部高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
